/**
 * 使用interrupt终止线程
 */
public class ThreadInterrupt2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(()->{
         //  while(!Thread.interrupted()){
          while(!Thread.currentThread().isInterrupted()){
               System.out.println("正在转账...");
           }
            System.out.println("啊?险些误了大事！");
        });
        thread.start();
        Thread.sleep(500);
        //终止线程
        thread.interrupt();
        System.out.println("有内鬼终止交易!");
    }
}
